package com.example.hotel.ease.web;

import com.example.hotel.ease.ex.ServiceCode;
import lombok.Data;

import java.io.Serializable;

@Data
public class JsonResult implements Serializable {
    private int state;
    private String message;
    private Object data;

    private JsonResult() {}

    public static JsonResult ok() {
        return ok(null);
    }

    public static JsonResult ok(Object data) {
        JsonResult result = new JsonResult();
        result.state = ServiceCode.OK.getCode();
        result.data = data;
        return result;
    }

    public static JsonResult fail(int state, String message) {
        JsonResult result = new JsonResult();
        result.state = state;
        result.message = message;
        return result;
    }
}